# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class ScriptTestItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    pass

#车辆信息模型
class CarItem(scrapy.Item):
    link = scrapy.Field()
    # 图片链接
    img = scrapy.Field()
    # 车名
    name = scrapy.Field()
    # 价格
    price = scrapy.Field()
    # 评分
    score = scrapy.Field()
    # 级别
    rank = scrapy.Field()
    # 车类型
    car_type = scrapy.Field()
    # 发动机
    engine = scrapy.Field()
    # 变速箱
    box = scrapy.Field()
    # 颜色
    color = scrapy.Field()

class YuehuiItem(scrapy.Item):
    nick = scrapy.Field()
    info_url = scrapy.Field()
    age = scrapy.Field()
    cityName = scrapy.Field()
    degreeName = scrapy.Field()
    animal = scrapy.Field()
    img = scrapy.Field()
    u_id = scrapy.Field()
    img_path = scrapy.Field()
    def get_sql(self):
        sql = "insert into yuehui values(null,%s,%s,%s,%s,%s,%s,%s,%s)"
        data = [self["nick"],self["info_url"],self["age"],self["cityName"],self["degreeName"],self["animal"],self["img_path"],self["u_id"]]
        return sql,data


class WangzheItem(scrapy.Item):
    hero_id = scrapy.Field()  #英雄id
    name = scrapy.Field()     #英雄name
    hero_type = scrapy.Field()#英雄类型
    exist = scrapy.Field()    #存活
    atk = scrapy.Field()      #攻击力
    skill = scrapy.Field()    #技能效果
    difficulty = scrapy.Field()#上手程度
    skill_show = scrapy.Field()#所有技能
    skin_kv = scrapy.Field()   #皮肤键值
    skin_url = scrapy.Field()  #皮肤url

    def get_sql(self):
        sql = "insert into wangzhe(hero_id,name,hero_type,exist,atk,skill,difficulty,skill_show,skin_kv,skin_url) values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)"
        data = [self["hero_id"],self["name"],self["hero_type"],self["exist"],self["atk"],self["skill"],self["difficulty"],self["skill_show"],self["skin_kv"],self["skin_url"]]
        return sql,data

class CnblogsItem(scrapy.Item):
    info_url = scrapy.Field()
    title = scrapy.Field()
    author = scrapy.Field()
    time = scrapy.Field()
    comment = scrapy.Field()
    view = scrapy.Field()
    diggnum = scrapy.Field()
    article = scrapy.Field()
    spider = scrapy.Field()

    def get_sql(self):
        sql = 'insert into cnblogs(info_url,title,author,time,comment,view,diggnum,article,spider) values (%s,%s,%s,%s,%s,%s,%s,%s,%s)'
        data = [self["info_url"],self["title"],self["author"],self["time"],self["comment"],self["view"],self["diggnum"],self["article"],self["spider"]]
        return sql,data